.text
addi $sp,$zero,2000

####
# SYSCALL CUSTOM 
# 1 : PLAYER TYPE FROM $a0
# 2 : ENEMY TYPE 0 FROM $a0
# 3 : ENEMY TYPE 1
# 4 : ENEMY TYPE 2
# 5 : ENEMY TYPE 3
# 6 : BULLET TYPE 0
# 7 : BULLET TYPE 1
# 8 : BULLET TYPE 2
# 9 : BULLET TYPE 3
# 10: EXIT
# 11: PLAYER POSITION
# 12: ENEMY 0 POSITION & TYPE
# 13: ENEMY 1 POSITION & TYPE
# ...
# 20: BULLET 0 POSITION & TYPE
# ...
# 28: LOCK POSITION
# 29: RELEASE POSITION
# 30: Player Move left
# 31: Player Move right
# 32: Player Move up
# 33: Player Move down
####
# shape s: 192c1498 e0
# shape t: 211e424c e1
# shape a: 11518aca e2
# shape r: 21d94210 e3
# shape p: 21d97210 b0
# shape l: 21084a98 b1
# shape n: 019a52d4 b2
# shape e: 01d1f45c b3
# shape w: 2a35add2 p0
####
# display : plane war start
# position: y=0 x p-8 l-16 a-32 n-40 e-48 
# position: y=8 x w-8      a-32      r-48
# position: y=24x s-8 t-16 a-32 r-40 t-48 
# p (b0) 8  0  0 20000000  20
# l (b1) 16 0  1 40020000  21
# a (e0) 32 0  2 80040000  12
# n (b2) 40 0  2 a0040000  22
# e (b3) 48 0  3 c0060000  23
# w (p0) 8  8  0 20400000  11
# a (e1) 32 8  2 80440000  13
# r (e2) 48 8  3 c0460000  14
# s (e3) 8  24 0 20c00000  15 
# t (e4) 16 24 1 40c20000  16
# a (e5) 24 24 2 60c40000  17
# r (e6) 40 24 3 a0c60000  18
# t (e7) 48 24 1 c0c20000  19
####
# shape e0: 0x1c48fdc4  2
# shape e1: 0x1c427c84  3
# shape e2: 0x1c4aedc4  4
# shape e3: 0x23b713f1  5
# shape b0: 0x00000084  6
# shape b1: 0x000002b5  7
# shape b2: 0x000011ca  8
# shape b3: 0x0000014a  9
# shape p0: 0x08423bea  1
###
# position: y=0 e 0 8 16 24 32 40 48 56
# position: y=120 p 28 
# position: y=0 b 63
# e0 0  0  0  0x0
# e1 8  0  1  0x20020000
# e2 16 0  2  0x40040000
# e3 24 0  3  0x60060000
# e4 32 0  2  0x80040000
# e5 40 0  1  0xa0020000
# e6 48 0  0  0xc0000000
# e7 56 0  1  0xe0020000
# b0 63 0  0  0xfc000000
# b7
# p  28 120 0 0x73c00000
####

.text
START:
### set game is not allowed to start
addi $s7,$zero,0
### add lock to position
addi $v0,$zero,28
syscall

## set type p0=>w
addi $t0,$zero,0x2a35
sll $t1,$t0,16
ori $a0,$t1,0xadd2
addi $v0,$zero,1
syscall

## set type e0=>s
addi $t0,$zero,0x192c
sll $t1,$t0,16
ori $a0,$t1,0x1498
addi $v0,$zero,2
syscall

## set type e1=>t
addi $t0,$zero,0x211e
sll $t1,$t0,16
ori $a0,$t1,0x424c
addi $v0,$zero,3
syscall

## set type e2=>a
addi $t0,$zero,0x1151
sll $t1,$t0,16
ori $a0,$t1,0x8aca
addi $v0,$zero,4
syscall

## set type e3=>r
addi $t0,$zero,0x21d9
sll $t1,$t0,16
ori $a0,$t1,0x4210
addi $v0,$zero,5
syscall

## set type b0=>p
addi $t0,$zero,0x21d9
sll $t1,$t0,16
ori $a0,$t1,0x7210
addi $v0,$zero,6
syscall

## set type b1=>l
addi $t0,$zero,0x2108
sll $t1,$t0,16
ori $a0,$t1,0x4a98
addi $v0,$zero,7
syscall

## set type b2=>n
addi $t0,$zero,0x19a
sll $t1,$t0,16
ori $a0,$t1,0x52d4
addi $v0,$zero,8
syscall

## set type b3=>e
addi $t0,$zero,0x1d1
sll $t1,$t0,16
ori $a0,$t1,0xf45c
addi $v0,$zero,9
syscall



## ## ## TO SET TITLES 

# p (b0) 8  0  0 20000000  20
# l (b1) 16 0  1 40020000  21
# a (e0) 32 0  2 80040000  12


## set type b0=>p
addi $t0,$zero,0x2000
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,20
syscall
## set type b1=>l
addi $t0,$zero,0x4002
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,21
syscall
## set type e0=>a
addi $t0,$zero,0x80
sll $t1,$t0,24
addi $t0,$zero,0x04
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,12
syscall

# n (b2) 40 0  2 a0040000  22
# e (b3) 48 0  3 c0060000  23
# w (p0) 8  8  0 20400000  11

## set type b2=>n
addi $t0,$zero,0xa0
sll $t1,$t0,24
addi $t0,$zero,0x04
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,22
syscall
## set type b3=>e
addi $t0,$zero,0xc0
sll $t1,$t0,24
addi $t0,$zero,0x06
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,23
syscall
## set type p0=>w
addi $t0,$zero,0x2040
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,11
syscall

# a (e1) 32 8  2 80440000  13
# r (e2) 48 8  3 c0460000  14
# s (e3) 8  24 0 20c00000  15 

## set type e1=>a
addi $t0,$zero,0x80
sll $t1,$t0,24
addi $t0,$zero,0x44
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,13
syscall
## set type e2=>r
addi $t0,$zero,0xc0
sll $t1,$t0,24
addi $t0,$zero,0x46
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,14
syscall
## set type e3=>s
addi $t0,$zero,0x20c0
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,15
syscall

# t (e4) 16 24 1 40c20000  16
# a (e5) 24 24 2 60c40000  17
# r (e6) 40 24 3 a0c60000  18
# t (e7) 48 24 1 c0c20000  19
## set type e4=>t
addi $t0,$zero,0x40c2
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,16
syscall
## set type e5=>a
addi $t0,$zero,0x60c4
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,17
syscall
## set type e6=>r
addi $t0,$zero,0xa0
sll $t1,$t0,24
addi $t0,$zero,0xc6
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,18
syscall
## set type e7=>t
addi $t0,$zero,0xc0
sll $t1,$t0,24
addi $t0,$zero,0xc2
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,19
syscall

### ### set game is allowed to start 
## s7 saves (allow game to start)
## :0 not allowed to start
## :1 ready to start
## :2 started
addi $s7,$zero,1

########################
WAIT_TO_START_LOOP:
## LOOP wait to start
addi $t0,$zero,2
bne $s7,$t0,WAIT_TO_START_LOOP
#######################

ENTERGAME:

## RESET ALL THE TYPE
# shape e0: 0x1c48fdc4  2
# shape e1: 0x1c427c84  3
# shape p0: 0x08423bea  1

## set type p0
addi $t0,$zero,0x0842
sll $t1,$t0,16
ori $a0,$t1,0x3bea
addi $v0,$zero,1
syscall

## set type e0
addi $t0,$zero,0x1c48
sll $t1,$t0,16
ori $a0,$t1,0xfdc4
addi $v0,$zero,2
syscall

## set type e1
addi $t0,$zero,0x1c42
sll $t1,$t0,16
ori $a0,$t1,0x7c84
addi $v0,$zero,3
syscall

# shape e2: 0x1c4aedc4  4
# shape e3: 0x23b713f1  5
# shape b0: 0x00000084  6

## set type e2
addi $t0,$zero,0x1c4a
sll $t1,$t0,16
ori $a0,$t1,0xedc4
addi $v0,$zero,4
syscall

## set type e3
addi $t0,$zero,0x23b7
sll $t1,$t0,16
ori $a0,$t1,0x13f1
addi $v0,$zero,5
syscall

## set type b0
addi $t0,$zero,0x0000
sll $t1,$t0,16
ori $a0,$t1,0x0084
addi $v0,$zero,6
syscall

# shape b1: 0x000002b5  7
# shape b2: 0x000011ca  8
# shape b3: 0x0000014a  9

## set type b1
addi $t0,$zero,0x0000
sll $t1,$t0,16
ori $a0,$t1,0x02b5
addi $v0,$zero,7
syscall

## set type b2
addi $t0,$zero,0x0000
sll $t1,$t0,16
ori $a0,$t1,0x11ca
addi $v0,$zero,8
syscall

## set type b3
addi $t0,$zero,0x0000
sll $t1,$t0,16
ori $a0,$t1,0x014a
addi $v0,$zero,9
syscall

### RESET ALL POSITION
# e0 0  0  0  0x0         12
# e1 8  0  1  0x20020000  13 
# e2 16 0  2  0x40040000  14

## set position p
addi $t0,$zero,0x73c0
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,11
syscall

## set position e0
addi $t0,$zero,0x0
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,12
syscall

## set position e1
addi $t0,$zero,0x2002
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,13
syscall

## set position e2
addi $t0,$zero,0x4004
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,14
syscall

# e3 24 0  3  0x60060000  15
# e4 32 0  2  0x80040000  16
# e5 40 0  1  0xa0020000  17
# e6 48 0  0  0xc0000000  18

## set position e3
addi $t0,$zero,0x6006
sll $t1,$t0,16
ori $a0,$t1,0x0
addi $v0,$zero,15
syscall

## set position e4
addi $t0,$zero,0x80
sll $t1,$t0,24
addi $t0,$zero,0x04
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,16
syscall

## set position e5
addi $t0,$zero,0xa0
sll $t1,$t0,24
addi $t0,$zero,0x02
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,17
syscall

## set position e6
addi $t0,$zero,0xc0
sll $t1,$t0,24
addi $t0,$zero,0x00
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,18
syscall

# e7 56 0  1  0xe0020000  19
# b0 63 0  0  0xfc000000  20
# b7                      27
# p  28 120 0 0x73c00000  11

## set position e7
addi $t0,$zero,0xe0
sll $t1,$t0,24
addi $t0,$zero,0x02
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,19
syscall

## set position b0
addi $t0,$zero,0xfc
sll $t1,$t0,24
addi $t0,$zero,0x00
sll $t2,$t0,16
or $a0,$t1,$t2
addi $v0,$zero,20
syscall
addi $v0,$zero,21
syscall
addi $v0,$zero,22
syscall
addi $v0,$zero,23
syscall
addi $v0,$zero,24
syscall
addi $v0,$zero,25
syscall
addi $v0,$zero,26
syscall
addi $v0,$zero,27
syscall


##  RELEASE LOCK OF POSITION
addi $v0,$zero,29
syscall

GAMELOOP:
nop
j GAMELOOP






## t4-t7 used
#### INT ->
### RIGHT KEY DOWN
INT_RIGHT:
## if game not start
# set key invalid
beq $s7,$zero,INT_RET

## if game is ready to start
addi $t7,$zero,1
beq $s7,$t7,INT_RIGHT_GAME_READY

## game start //set player to move
addi $v0,$zero,31
syscall
eret

INT_RIGHT_GAME_READY:
addi $s7,$zero,2
INT_RET:
eret



### LEFT KEY DOWN
INT_LEFT:
addi $t6,$zero,2
bne $s7,$t6,INT_RET
## game start //set player to move
addi $v0,$zero,30
syscall
eret


### UP KEY DOWN
INT_UP:
addi $t6,$zero,2
bne $s7,$t6,INT_RET
## game start //set player to move
addi $v0,$zero,32
syscall
eret


### DOWN KEY DOWN
INT_DOWN:
addi $t6,$zero,2
bne $s7,$t6,INT_RET
## game start //set player to move
addi $v0,$zero,33
syscall
eret
